package vn.conghuy.talkwithme.responsor.subresponsor;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import vn.conghuy.talkwithme.MyApp;
import vn.conghuy.talkwithme.data.sqlmodel.SqlData;
import vn.conghuy.talkwithme.responsor.responsor.MapResponsor;
import vn.conghuy.talkwithme.responsor.responsor.Responsor;
import vn.conghuy.talkwithme.utils.StringWrapper;
import vn.conghuy.talkwithme.utils.Utils;
import android.content.Context;

public class MyLocationSubResponsor {
	
	MapResponsor mapResponsor;
	MyApp myApp;
	Context context;
	
	public MyLocationSubResponsor(MapResponsor mapResponsor, Context context) {
		this.mapResponsor = mapResponsor;
		this.context = context;
		myApp = (MyApp)context.getApplicationContext();
	}
	
	public String response(String request){
		if(mapResponsor.getRelativeLastResponse() == Responsor.RELATIVE_NONE){
			if(Utils.isStringMatchRegexInArray(request, SqlData.myLocationAskRegexes)){
				return myLocation();
			}
		}
		return null;
	}
	
	private String myLocation(){
		
		StringWrapper outLocaitonNameWrapper = new StringWrapper();
		vn.conghuy.talkwithme.android.utils.Utils.myLocation(myApp.locationManager, context, outLocaitonNameWrapper);
		return outLocaitonNameWrapper.getStr();
	}
}
